package top.hmtools.restRibbon.configuration;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;

@Configuration
public class MainConfiguration {

	@Bean
    @LoadBalanced//负载均衡，缺省为 轮询策略
    RestTemplate restTemplate() {
        return new RestTemplate();
    }
	
	/**
	 * 设置负载均衡策略
	 * @return
	 */
	@Bean
	IRule iRule(){
		//随机策略
		return new RandomRule();
	}
}
